package com.dzwww.recommend.rule.service.common.impl;

import com.alibaba.druid.support.json.JSONUtils;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dzwww.recommend.rule.common.bo.PageQuery;
import com.dzwww.recommend.rule.common.po.Rule;
import com.dzwww.recommend.rule.dao.mapper.RuleMapper;
import com.dzwww.recommend.rule.service.common.RuleService;
import com.dzwww.recommend.rule.service.base.impl.BaseServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.apache.servicecomb.foundation.common.utils.JsonUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Auto
 * @since 2019-07-16
 */
@Service
public class RuleServiceImpl extends BaseServiceImpl<RuleMapper, Rule> implements RuleService {

    /**
     * 分页查询，模糊查询
     */
    @Override
    public Page<Rule> listPage(Page<Rule> page,String name) {
        if(StringUtils.isBlank(name)){
            Page<Rule> pageResult = (Page<Rule>)super.page(page);
            return pageResult;
        }
        QueryWrapper<Rule> wrapper = new QueryWrapper<>();
        wrapper.lambda().like(Rule::getName,name);
        Page<Rule> pageResultParam = (Page<Rule>)super.page(page, wrapper);
        return pageResultParam;
    }
}
